package com.example.flowable.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.example.annotations.Autowired;
import com.example.annotations.Service;
import com.example.db.SqlBuilder;
import com.example.db.TableService;
import com.example.db.model.IPage;
import com.example.flowable.model.FormModel;
import com.example.flowable.service.FormModelService;

/**
 * @Classname FormModelServiceImpl
 * @Description TODO
 * @Date 2022/8/16 11:15
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@Service
public class FormModelServiceImpl implements FormModelService {

    @Autowired
    TableService tableService;

    @Override
    public FormModel getFormModelById(Object id) {
        FormModel formModel=tableService.getOneById(id,FormModel.class);
        return formModel;
    }

    @Override
    public IPage<FormModel> page(Integer pageNum, Integer pageSize, JSONObject object) {
        SqlBuilder sqlBuilder=tableService.getSqlBuilder(FormModel.class);
        if(object != null){

        }
        sqlBuilder.orderByDesc("createdate");
        sqlBuilder.page(pageNum,pageSize);
        return tableService.getPage(sqlBuilder,FormModel.class);
    }

    @Override
    public FormModel updateById(FormModel formModel) {
        tableService.updateById(formModel,FormModel.class);
        return formModel;
    }

    @Override
    public FormModel save(FormModel formModel) {
        tableService.save(formModel,FormModel.class);
        return formModel;
    }
}
